{template '_header'}
<style type="text/css">
    .imgScale.imgScale.imgScale{position: relative;background-size: 0;}
    .imgScale:after{content:'';position: absolute;top:-30px;left: -120px;z-index: 8;width: 120px;height: 120px;background: inherit;background-size: cover;background-position: center;background-repeat: no-repeat;display: block;opacity: 0;box-shadow: 0 0 5px rgba(0,0,0,.5);transition: all .5s;}
    .imgScale:hover::after{opacity: 1;}
    .imgScale:hover{overflow: inherit;}
</style>
<div class="page-header">
    当前位置：<span class="text-primary"> 身份管理 </span>
</div>
<div class="page-content">
<form action="{php echo webUrl('identity/user')}" method="get" class="form-horizontal" role="form" id="form1">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="ewei_shopv2" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r" value="identity.user" />

    <div class="page-toolbar m-b-sm m-t-sm">
        <div class="col-sm-3">
            <span class='pull-left'>
                <a class='btn btn-primary btn-sm' href="{php echo webUrl('identity/user/add')}"><i class="fa fa-plus"></i> 添加身份</a>
            </span>
        </div>

        <div class="col-sm-8 pull-right">
            <div class="input-group">
                <div class="input-group-select">
                    <select name='status' class='form-control  input-sm select-md' style="width:100px;"  >
                        <option value='0'>状态</option>
                        <option value='2' {if $_GPC['status']=='2'}selected{/if}>未审核</option>
                        <option value='1' {if $_GPC['status']=='1'}selected{/if}>已审核</option>
                        <option value='3' {if $_GPC['status']=='-1'}selected{/if}>已过期</option>
                    </select>
                </div>
                <input type="text" class="form-control input-sm"  name="keyword" value="{$_GPC['keyword']}" placeholder="用户名称/用户等级/分销等级"/>
				<span class="input-group-btn">
                    <button class="btn btn-primary" type="submit"> 搜索</button>
				</span>
            </div>

        </div>
    </div>
</form>
{if count($list)>0}
<div class="page-table-header">
    <input type="checkbox">
    <div class="btn-group">
        {ifp 'identity.user.edit'}
        <a class='btn btn-default btn-sm btn-operation'  data-toggle='batch' data-href="{php echo webUrl('identity/user/status',array('status'=>1))}"  data-confirm='确认要启用该身份用户吗?'>
            <i class="icow icow-qiyong"></i>启用
        </a>
        <a class='btn btn-default btn-sm btn-operation'  data-toggle='batch' data-href="{php echo webUrl('identity/user/status',array('status'=>0))}" data-confirm='确认要禁用该身份用户吗?'>
            <i class="icow icow-jinyong"></i>禁用
        </a>
        
        {/if}
        {ifp 'identity.user.delete'}
        <a class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo webUrl('identity/user/delete')}">
            <i class='icow icow-shanchu1'></i> 删除
        </a>
        {/if}
    </div>
</div>

<table class="table table-responsive table-hover" >
    <thead class="navbar-inner">
    <tr>
        <th style="width:40px;"></th>
        <th style="width:150px;">身份名称</th>
        <th style="width:100px;">会员等级</th>
        <th style="width:100px;">到期会员等级</th>
        <th style="width:120px;">分销等级</th>
        <th style="width:120px;">到期分销等级</th>
        <th style="width:70px;">二维码</th>
        <th>路径</th>
        <th style="width:80px;">有效天数</th>
        <th style="width:80px;">状态</th>
        <th style="width:80px;">操作</th>
    </tr>
    </thead>
    
    <tbody>
    {loop $list $row}
    <tr>
        <td>
            {if $row['levelnum'] != 0}<input type='checkbox'   value="{$row['id']}"/>{/if}
        </td>
     
        <td title="{$row['name']}">{$row['name']}</td>
        <td title="{$row['shop_user_grade']}">{$row['shop_user_grade']}</td>
        <td title="{$row['end_shop_user_grade']}">{$row['end_shop_user_grade']}</td>
        <td title="{$row['distribution_grade']}">{$row['distribution_grade']}</td>
        <td title="{$row['end_distribution_grade']}">{$row['end_distribution_grade']}</td>
        {if $row['levelnum'] != '0'}
        <td class="imgScale" data-id="{$row['buy_goods_id']}">
            <i class="glyphicon glyphicon-qrcode" style=" transform: scale(1.3);"></i>
        </td>
        <td><a href='javascript:;' class="js-clip" title='点击复制链接' data-url="{$row['url']}" title="{$row['url']}">{$row['url']}</a></td>
        {else}
        <td></td>
        <td></td>
        {/if}
        <th>{$row['useful_time']}</th>
        <td>
            {if $row['levelnum'] != 0}
            <span class='label {if $row['status']==1}label-primary{else}label-default{/if}'
            {ifp 'identity.user.edit'}
            data-toggle='ajaxSwitch'
            data-switch-value='{$row['status']}'
            data-switch-value0='0|已到期|label label-default|{php echo webUrl('identity/user/status',array('status'=>1,'id'=>$row['id']))}'
            data-switch-value1='1|使用中|label label-success|{php echo webUrl('identity/user/status',array('status'=>0,'id'=>$row['id']))}'
            {/if} >
            {if $row['status']==1}使用中{else}已到期{/if}
            </span>
            {/if}
        </td>
        <td style="text-align:left;">

            {ifp 'identity.user.view|identity.user.edit'}
            <a href="{php echo webUrl('identity/user/edit', array('id' => $row['id']))}" class="btn btn-default btn-sm btn-op btn-operation">
                  <span data-toggle="tooltip" data-placement="top" title="" data-original-title=" {ifp 'identity.group.edit'}修改{else}查看{/if}">
                    <i class='icow icow-bianji2'></i>
               </span>
            </a>
            {/if}

            {if $row['levelnum'] != 0}
            <a data-toggle='ajaxRemove' class="btn btn-default btn-sm btn-op btn-operation ajaxRemove" data-confirm='确认要删除该身份吗?' href="{php echo webUrl('identity/user/delete', array('id'=>$row['id']))}" identityid="$row['id']">
              <span data-toggle="tooltip" data-placement="top" title="" data-original-title="删除">
                     <i class='icow icow-shanchu1'></i>
                </span></a>
            {/if}
        </td>
    </tr>
    {/loop}
    </tbody>
    <tfoot>
        <tr>
            <td><input type="checkbox"></td>
            <td colspan="5">
                <div class="btn-group">
                    {ifp 'identity.user.edit'}
                    <a class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch' data-href="{php echo webUrl('identity/user/status',array('status'=>1))}"><i class='icow icow-qiyong'></i> 启用</a>
                    <a class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch'  data-href="{php echo webUrl('identity/user/status',array('status'=>0))}"><i class='icow icow-jinyong'></i> 禁用</a>
                    {/if}
                    
                    <a class="btn btn-default btn-sm btn-operation" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo webUrl('identity/user/delete')}"><i class='icow icow-shanchu1'></i> 删除</a>
                    
                </div>
            </td>
            <td colspan="4" class="text-right">
                {$pager}
            </td>
        </tr>
    </tfoot>
</table>

{else}
<div class='panel panel-default'>
    <div class='panel-body' style='text-align: center;padding:30px;'>
        暂时没有任何身份用户!
    </div>
</div>
{/if}
    </div>
<script type="text/javascript">
        $(function() {
            $('.imgScale').hover(function() {
                var KeyId = $(this).data('id'),
                    that = $(this),
                    isKeyFlag = false;    
                if(!isKeyFlag){
                    isKeyFlag = true;
                    $.get('{php echo webUrl("identity/user/qrcode")}&goods_id='+KeyId,function(result){
                        var resultData = JSON.parse(result);
                        if(resultData.code=="1"){
                            that.attr('style','background-image:url('+resultData.qrcode+')');
                            isKeyFlag = false;    
                        }


                    })    
                }    

            })

        })
    </script>

{template '_footer'}
<!--6Z2S5bKb5piT6IGU5LqS5Yqo572R57uc56eR5oqA5pyJ6ZmQ5YWs5Y+4-->